<?php
use yii\helpers\Html;
use yii\helpers\Url;
use app\lib\WeixinUtils;

/* @var $this yii\web\View */
/* @var $content string 字符串 */


$web = Url::to("@web");

?>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>产品详情</title>
    <link type="text/css" href="<?= $web ?>/css/bag/goods_detail_style.css" rel="stylesheet"/>
    <link type="text/css" href="<?= $web ?>/css/bag/goods_detail.css" rel="stylesheet"/>
    <link type="text/css" href="<?= $web ?>/css/bag/global.css" rel="stylesheet"/>
    <style type="text/css">
        /*  .main_image li .img_1{
              background:url(
        <?=$web?>
        /img/bag/goods_detail_image/s.png);
                    -webkit-background-size: 100%;
                }
              */
        div.flicking_con a {
            background: url('<?=$web?>/img/bag/goods_detail_image/btn_main_img.png') 0 0 no-repeat;
            background-size: 100%;
        }
    </style>
    <script type="text/javascript" src="<?= $web ?>/js/jquery.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/tools.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/bag/jquery.event.drag-1.5.min.js"></script>
    <script type="text/javascript" src="<?= $web ?>/js/bag/jquery.touchSlider.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".main_visual").hover(function () {
                $("#btn_prev,#btn_next").fadeIn()
            }, function () {
                $("#btn_prev,#btn_next").fadeOut()
            });

            $dragBln = false;

            $(".main_image").touchSlider({
                flexible: true,
                speed: 200,
                btn_prev: $("#btn_prev"),
                btn_next: $("#btn_next"),
                paging: $(".flicking_con a"),
                counter: function (e) {
                    $(".flicking_con a").removeClass("on").eq(e.current - 1).addClass("on");
                }
            });

            $(".main_image").bind("mousedown", function () {
                $dragBln = false;
            });

            $(".main_image").bind("dragstart", function () {
                $dragBln = true;
            });

            $(".main_image a").click(function () {
                if ($dragBln) {
                    return false;
                }
            });

            timer = setInterval(function () {
                $("#btn_next").click();
            }, 5000);

            $(".main_visual").hover(function () {
                clearInterval(timer);
            }, function () {
                timer = setInterval(function () {
                    $("#btn_next").click();
                }, 5000);
            });

            $(".main_image").bind("touchstart", function () {
                clearInterval(timer);
            }).bind("touchend", function () {
                timer = setInterval(function () {
                    $("#btn_next").click();
                }, 5000);
            });

            $(function () {
                // 任何需要执行的js特效
                var w = $(document).width();
                if (w > 640) {
                    w = 640;
                }
                $("body").css("font-size", w * 20 / 320);
            });
        });

        function addCart(goods_code){
            var data={};
            data.goods_code=goods_code;
            var re=returnjson('<?=Url::to(['wx-bag/add-goods-to-cart-handle'])?>',data);
            if (re.flag == 0) {
                alert(re.msg);
                return;
            } else {
                $('#v_TOTALNUM').html(re.TOTALNUM);
                alert('加入购物车成功');
            }
        }
        function href_cart(){
            window.location.href = "<?=Url::to(["wx-bag/shopping-cart"]);?>";
        }
    </script>
</head>
<body>

<div class="main">
    <div class="carousel" style="display:none;">
        <div class="kePublic">
            <div class="main_visual">
                <div class="flicking_con">
                    <?php

                    for ($i = 0; $i <= count($imgList) - 1; $i++) {
                        ?>
                        <a href="#"></a>
                        <?php
                    }
                    ?>
                    <!-- <a href="#"></a>-->

                </div>
                <div class="main_image">
                    <ul>
                        <?php
                        for ($i = 0; $i <= count($imgList) - 1; $i++) {
                            $img = $imgList[$i];
                            $url = $img['GOODS_EXHI_URL'] == null ? $url = $web . '/logo.jpg' : $img['GOODS_EXHI_URL'];
                            ?>
                            <li>
                                <div style="background:url(<?= $url ?>);"></div>
                            </li>
                            <?php
                        }
                        ?>
                        <!-- <li><span style=" background:url(<? /*=$web*/ ?>/img/bag/goods_detail_image/s.png);-webkit-background-size: 100%;"></span></li>-->

                    </ul>
                    <a href="javascript:;" id="btn_prev"></a>
                    <a href="javascript:;" id="btn_next"></a>
                </div>
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="hr"></div>
    <div class="message">
        <div class="message_title"><label><?= $goods['GOODS_NAME'] ?></label></div>
        <table class="message_table" cellpadding="0" cellspacing="0" border="0">
            <tr style="height: 1em;">
                <td>
                    <div
                        style="width:7.5em; line-height: 1em; word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; color:rgb(102,102,102); margin-left:0.5em;">
                        <label style="font-size: 0.6em;">规格:<?= $goods['GOODS_SPEC'] ?></label>
                    </div>
                </td>
                <td>
                    <div
                        style="width:7.5em; line-height: 1em; word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; color:rgb(102,102,102); margin-left:0.5em;">
                        <label style="font-size: 0.6em;">型号:<?= $goods['GOODS_TYPE'] ?></label>
                    </div>
                </td>
            </tr>
            <tr style="height: 1em;">
                <td>
                    <div
                        style="width:7.5em; line-height: 1em; word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; color:rgb(102,102,102); margin-left:0.5em;">
                        <label style="font-size: 0.6em;">品牌:<?= $goods['GOODS_PINPAI'] ?></label>
                    </div>
                </td>
                <td></td>
            </tr>
        </table>
    </div>
    <div class="hr" style="margin-top:0.5em;"></div>
    <div class="message_down">
        <div class="message_down_text">
            <?= $goods['GOODS_DETAIL_HTML'] ?>
        </div>
    </div>
    <div style="height: 2.5em;" style="display: none;"></div>
    <div class="down_ab" style="display: none;">
        <div class="down_ab_left">
            <div class="down_ab_left_text">朵拉价：¥<?= $goods['PRICE'] ?></div>
        </div>
        <div class="down_ab_center" onclick="href_cart()">
            <img src="<?= $web ?>/img/bag/goods_detail_image/cart.png"
                 style="width: 1.5em; margin-left: 0.75em; margin-top: 0.5em;"/>
            <div class="down_ab_center_num"><label id="v_TOTALNUM"><?=$TOTALNUM?></label></div>
        </div>
        <div class="down_ab_rigth" onclick="addCart('<?=$goods['GOODS_CODE']?>');">
            <label>加入礼包</label>
        </div>
    </div>

</div>

</body>
</html>
